/*
 *  NativeRenderer.h
 *  
 *
 *  Created by Bongju Kim on 11. 2. 15..
 *  Copyright 2011 myastro. All rights reserved.
 *
 */

#if !defined(_NATIVEMAPMATCH_H_)
#define _NATIVEMAPMATCH_H_

#include <jni.h>

// NeHe.ES.lesson
#include <lesson.h>
//#include <Common/Interfaces.hpp>	//
#include <Interfaces.hpp>
//#include "./iPhone3D.Programming/SimpleWireframe/Classes/Interfaces.hpp"
//#include "./iPhone3D.Programming/ObjViewer/Classes/Interfaces.hpp"

class CNativeRenderer
{
public:
	CNativeRenderer();
	CNativeRenderer(JNIEnv *env, jobject* jobj);
	virtual ~CNativeRenderer();
	
	static CNativeRenderer *getInstance();

	jint	init(JNIEnv *env, jstring jpath);
	void 	initiate();
	
	void 	appInit();
	void 	appDeinit();
	void 	appRender(long tick, int width, int height);
	void    appResize(int width, int height);
	void	appPause();
	void	appDone();
	void 	appHandleKeyPress(int keycode, bool pressed);
	void	appTouchEvent(int pointer_id, int actionCode, float x, float y);

private:
	JavaVM*		m_jvm;
	JNIEnv*		m_env;
	jobject		m_obj;
	jmethodID	m_sendStr;
	jclass		m_jNativeCls;

	// NeHe.ES lesson interface
	INeHe_ES_lesson* m_pLesson;

	IRenderingEngine* m_pRenderingEngine;
	IApplicationEngine* m_pApplicationEngine;


	int  nTimeOffsetInit;
	long nTimeOffset;
	long nTimeStopped;
	char whichLesson[16];
	bool bStopRenderer;

	bool bIsNeHeLesson;
	long m_timestamp;

	ivec2 oldLocation;

};

#endif
